from django.db import models
from django.contrib.auth.models import User
from accounts.models import UserProfile
from mailaux import sendEmail

# Create your models here.
class Dmail(models.Model):
    sender = models.EmailField(max_length=200)
    receiver = models.EmailField(max_length=200)
    subject = models.CharField(max_length=200)
    body = models.CharField(max_length=2000)
    user = models.ForeignKey(User)
    date = models.DateField()
    time = models.TimeField()
    sent = models.BooleanField()
    def __unicode__(self):
        return self.sender + "/" + self.receiver + "/" + self.subject

    def send(self):
        try:
            self.sent = sendEmail(self.receiver,self.subject,self.body)
            self.save()
        except:
            pass

        
